import 'package:flutter/material.dart';
import 'package:haitao_app/config/config.dart';
import 'package:haitao_app/table/resp_result.dart';


class GoodsItem extends StatelessWidget{

  RstData data;
  GestureTapCallback callback;

  GoodsItem({this.data,this.callback});

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return _indexItem(data);
  }

// ignore: slash_for_doc_comments
  /** 首页列表item ***/
  Widget _indexItem(RstData data){
    return SizedBox(
      height: 110,
      child: GestureDetector(
        child: Container(
          decoration: BoxDecoration(
//            borderRadius: BorderRadius.all(Radius.circular(10)),
            border: Border.all(color: Colors.black54,width: 1),
          ),
          padding: EdgeInsets.only(bottom: 5,top: 5),
          margin: EdgeInsets.all(5),
          child: Row(
            children: <Widget>[
              _indexItemLeft(data.image),
              _indexItemRight(data),
            ],
          ),
        ),
        onTap: callback,
      ),
    );
  }
  // ignore: slash_for_doc_comments
  /** item左侧 ***/
  Widget _indexItemLeft(String path){
    return Container(
      width: 100,
      height: 100,
      child: Image.network(path),
    );
  }
  // ignore: slash_for_doc_comments
  /** item右侧 ***/
  Widget _indexItemRight(RstData data){
    return Expanded(
      child: Column(
        children: <Widget>[
          _rightTop(data.title),
          _rightFoot(data.mall, data.fromsite, data.pubtime)
        ],
      ),
    );
  }
// ignore: slash_for_doc_comments
  /** item右侧  上部分***/
  Widget _rightTop(String title){
    return Container(
      alignment: Alignment.topLeft,
      child: Text(title),
    );
  }
// ignore: slash_for_doc_comments
  /** item右侧  下部分***/
  Widget _rightFoot(String mall,String from,String time){
    return Expanded(
      child: Container(
        alignment: Alignment.bottomLeft,
        child: Row(
          children: <Widget>[
            Expanded(
              flex: 1,
              child: Container(
                alignment: Alignment.bottomLeft,
                child: Text(mall,style: TextStyle(color: Color.fromARGB(255, 0, 175, 0),fontSize: 10),),
              ),
            ),
            Expanded(
              flex: 2,
              child: Container(
                margin: EdgeInsets.only(right: 3),
                alignment: Alignment.bottomRight,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: <Widget>[
                    Text("$from·",style: TextStyle(color: Colors.grey,fontSize: 10),),
                    Text(time,style: TextStyle(color: Color.fromARGB(255, 0, 175, 0),fontSize: 10),),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

}